home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / biz / haage / WarpUP_V31.lha / WarpUP-WarpOS / include / powerpc / powerpc.i < prev    next >
Text File  |  1998-03-06  |  22KB  |  756 lines

  1.         IFND POWERPC_POWERPC_I
  2. POWERPC_POWERPC_I       SET 1
  3. **
  4. **      $VER: PowerPC.i 14.0 (5.3.98)
  5. **
  6. **      Hardware and communication related structures and macros
  7. **      for the powerpc.library
  8. **
  9.         IFND    POWERPC_PPCMACROS_I
  10.         include powerpc/ppcmacros.i
  11.         ENDC
  12.  
  13.         IFND    EXEC_TYPES_I
  14.         include exec/types.i
  15.         ENDC
  16.  
  17.         IFND    UTILITY_TAGITEM_I
  18.         include utility/tagitem.i
  19.         ENDC
  20.  
  21.  
  22.         IFND    POWERPCLIB_V7           ;only for V8+
  23.  
  24. ****  tagitem values for GetHALInfo (V14+)
  25.  
  26.     ENUM            TAG_USER+$103000
  27.     EITEM           HINFO_ALEXC_HIGH        ;High word of emulated
  28.                         ;alignment exceptions
  29.     EITEM           HINFO_ALEXC_LOW         ;Low word of ...
  30.  
  31. ****  tagitem values for SetScheduling (V14+)
  32.  
  33.     ENUM            TAG_USER+$104000
  34.     EITEM           SCHED_REACTION          ;reaction of low activity tasks
  35.  
  36. ****  tagitem values for GetInfo
  37.  
  38.     ENUM            TAG_USER+$102000
  39.     EITEM           PPCINFO_CPU             ;CPU type (see below)
  40.     EITEM           PPCINFO_PVR             ;PVR value
  41.     EITEM           PPCINFO_ICACHE          ;Instruction cache state
  42.     EITEM           PPCINFO_DCACHE          ;Data cache state
  43.     EITEM           PPCINFO_PAGETABLE       ;Page table location
  44.     EITEM           PPCINFO_TABLESIZE       ;Page table size
  45.     EITEM           PPCINFO_BUSCLOCK        ;PPC bus clock
  46.     EITEM           PPCINFO_CPUCLOCK        ;PPC CPU clock
  47.     EITEM           PPCINFO_CPULOAD         ;Total CPU usage *100 [%]
  48.     EITEM           PPCINFO_SYSTEMLOAD      ;Total system load *100 [%]
  49.  
  50. ****  PPCINFO_ICACHE / PPCINFO_DCACHE
  51.  
  52.     BITDEF          CACHE,ON_UNLOCKED,0     ;cache is on and unlocked
  53.     BITDEF          CACHE,ON_LOCKED,1       ;cache is on and locked
  54.     BITDEF          CACHE,OFF_UNLOCKED,2    ;cache is off and unlocked
  55.     BITDEF          CACHE,OFF_LOCKED,3      ;cache is off and locked
  56.  
  57. **** Cache flags (required by SetCache)
  58.  
  59. CACHE_DCACHEOFF         =       1
  60. CACHE_DCACHEON          =       2
  61. CACHE_DCACHELOCK        =       3
  62. CACHE_DCACHEUNLOCK      =       4
  63. CACHE_DCACHEFLUSH       =       5
  64. CACHE_ICACHEOFF         =       6
  65. CACHE_ICACHEON          =       7
  66. CACHE_ICACHELOCK        =       8
  67. CACHE_ICACHEUNLOCK      =       9
  68. CACHE_ICACHEINV         =       10
  69.  
  70. **** Hardware flags (required by SetHardware)
  71.  
  72. HW_TRACEON              =       1               ;enable singlestep mode
  73. HW_TRACEOFF             =       2               ;disable singlestep mode
  74. HW_BRANCHTRACEON        =       3               ;enable branch trace mode
  75. HW_BRANCHTRACEOFF       =       4               ;disable branch trace mode
  76. HW_FPEXCON              =       5               ;enable FP exceptions
  77. HW_FPEXCOFF             =       6               ;disable FP exceptions
  78. HW_SETIBREAK            =       7               ;set instruction breakpoint
  79. HW_CLEARIBREAK          =       8               ;clear instruction breakpoint
  80. HW_SETDBREAK            =       9               ;set data breakpoint (604[E] only)
  81. HW_CLEARDBREAK          =       10              ;clear data breakpoint (604[E] only)
  82.  
  83. **** return values of SetHardware
  84.  
  85. HW_AVAILABLE            =       -1              ;feature available
  86. HW_NOTAVAILABLE         =       0               ;feature not available
  87.  
  88. **** return values of GetPPCState
  89.  
  90.         BITDEF  PPCSTATE,POWERSAVE,0    ;PPC is in power save mode
  91.         BITDEF  PPCSTATE,APPACTIVE,1    ;PPC application tasks are active
  92.         BITDEF  PPCSTATE,APPRUNNING,2   ;PPC application task is running
  93.  
  94. **** FP flags (required by ModifyFPExc)
  95.  
  96.         BITDEF  FP,EN_OVERFLOW,0        ;enable overflow exception
  97.         BITDEF  FP,EN_UNDERFLOW,1       ;enable underflow exception
  98.         BITDEF  FP,EN_ZERODIVIDE,2      ;enable zerodivide exception
  99.         BITDEF  FP,EN_INEXACT,3         ;enable inexact op. exception
  100.         BITDEF  FP,EN_INVALID,4         ;enable invalid op. exception
  101.         BITDEF  FP,DIS_OVERFLOW,5       ;disable overflow exception
  102.         BITDEF  FP,DIS_UNDERFLOW,6      ;disable underflow exception
  103.         BITDEF  FP,DIS_ZERODIVIDE,7     ;disable zerodivide exception
  104.         BITDEF  FP,DIS_INEXACT,8        ;disable inexact op. exception
  105.         BITDEF  FP,DIS_INVALID,9        ;disable invalid op. exception
  106.  
  107. FPF_ENABLEALL   =       $0000001f               ;enable all FP exceptions
  108. FPF_DISABLEALL  =       $000003e0               ;disable all FP exceptions
  109.  
  110. **** tags passed to SetExcHandler (exception handler attributes)
  111.  
  112.     ENUM            TAG_USER+$101000
  113.     EITEM           EXCATTR_CODE            ;-> exception code (required)
  114.     EITEM           EXCATTR_DATA            ;exception data
  115.     EITEM           EXCATTR_TASK            ;task if task dependant exc.
  116.                         ;0 for current task
  117.     EITEM           EXCATTR_EXCID           ;exception ID
  118.     EITEM           EXCATTR_FLAGS           ;see below
  119.     EITEM           EXCATTR_NAME            ;identification name
  120.     EITEM           EXCATTR_PRI             ;handler priority
  121.  
  122. **** EXCATTR_FLAGS (either EXC_GLOBAL or EXC_LOCAL, resp.
  123. *                   EXC_SMALLCONTEXT or EXC_LARGECONTEXT must be
  124. *                   specified)
  125.  
  126.     BITDEF          EXC,GLOBAL,0            ;global handler
  127.     BITDEF          EXC,LOCAL,1             ;task dependant handler
  128.     BITDEF          EXC,SMALLCONTEXT,2      ;small context structure
  129.     BITDEF          EXC,LARGECONTEXT,3      ;large context structure
  130.     BITDEF          EXC,ACTIVE,4            ;private
  131.  
  132. **** EXCATTR_EXCID (Exception ID)
  133.  
  134.     BITDEF          EXC,MCHECK,2            ;machine check exception
  135.     BITDEF          EXC,DACCESS,3           ;data access exception
  136.     BITDEF          EXC,IACCESS,4           ;instruction access exception
  137.     BITDEF          EXC,ALIGN,6             ;alignment exception
  138.     BITDEF          EXC,PROGRAM,7           ;program exception
  139.     BITDEF          EXC,FPUN,8              ;FP unavailable exception
  140.     BITDEF          EXC,TRACE,13            ;trace exception
  141.     BITDEF          EXC,PERFMON,15          ;performance monitor exception
  142.     BITDEF          EXC,IABR,19             ;IA breakpoint exception
  143.  
  144. **** Large exception context structure (if EXCATTR_LARGECONTEXT was set)
  145.  
  146.     STRUCTURE       EXCCONTEXT,0
  147.     ULONG           EC_EXCID        ;exception ID (see above)
  148.     ULONG           EC_SRR0         ;process' program counter
  149.     ULONG           EC_SRR1         ;process' context
  150.     ULONG           EC_DAR          ;DAR register
  151.     ULONG           EC_DSISR        ;DSISR register
  152.     ULONG           EC_CR           ;condition register
  153.     ULONG           EC_CTR          ;count register
  154.     ULONG           EC_LR           ;link register
  155.     ULONG           EC_XER          ;integer exception register
  156.     ULONG           EC_FPSCR        ;FP status register
  157.     STRUCT          EC_GPR,32*4     ;r0 - r31
  158.     STRUCT          EC_FPR,32*8     ;f0 - f31
  159.     LABEL           EC_SIZE         ;don't depend on this size
  160.  
  161. ****  Symbolic offsets into the register arrays
  162.  
  163. __r0            =       0*4
  164. __r1            =       1*4
  165. __r2            =       2*4
  166. __r3            =       3*4
  167. __r4            =       4*4
  168. __r5            =       5*4
  169. __r6            =       6*4
  170. __r7            =       7*4
  171. __r8            =       8*4
  172. __r9            =       9*4
  173. __r10           =       10*4
  174. __r11           =       11*4
  175. __r12           =       12*4
  176. __r13           =       13*4
  177. __r14           =       14*4
  178. __r15           =       15*4
  179. __r16           =       16*4
  180. __r17           =       17*4
  181. __r18           =       18*4
  182. __r19           =       19*4
  183. __r20           =       20*4
  184. __r21           =       21*4
  185. __r22           =       22*4
  186. __r23           =       23*4
  187. __r24           =       24*4
  188. __r25           =       25*4
  189. __r26           =       26*4
  190. __r27           =       27*4
  191. __r28           =       28*4
  192. __r29           =       29*4
  193. __r30           =       30*4
  194. __r31           =       31*4
  195. __f0            =       0*8
  196. __f1            =       1*8
  197. __f2            =       2*8
  198. __f3            =       3*8
  199. __f4            =       4*8
  200. __f5            =       5*8
  201. __f6            =       6*8
  202. __f7            =       7*8
  203. __f8            =       8*8
  204. __f9            =       9*8
  205. __f10           =       10*8
  206. __f11           =       11*8
  207. __f12           =       12*8
  208. __f13           =       13*8
  209. __f14           =       14*8
  210. __f15           =       15*8
  211. __f16           =       16*8
  212. __f17           =       17*8
  213. __f18           =       18*8
  214. __f19           =       19*8
  215. __f20           =       20*8
  216. __f21           =       21*8
  217. __f22           =       22*8
  218. __f23           =       23*8
  219. __f24           =       24*8
  220. __f25           =       25*8
  221. __f26           =       26*8
  222. __f27           =       27*8
  223. __f28           =       28*8
  224. __f29           =       29*8
  225. __f30           =       30*8
  226. __f31           =       31*8
  227.  
  228.  
  229. **** Small exception context structure (if EXCATTR_SMALLCONTEXT was set)
  230.  
  231.     STRUCTURE       XCONTEXT,0
  232.     ULONG           XCO_EXCID       ;exception ID (see above)
  233.     ULONG           XCO_R3          ;r3
  234.     LABEL           XCO_SIZE        ;don't depend on this size
  235.  
  236. **** Possible return values for exception handlers
  237.  
  238. EXCRETURN_NORMAL        =       0       ;allow the next exc handlers to complete
  239. EXCRETURN_ABORT         =       1       ;exception is immediately leaved, all
  240.                     ;other exception handlers are ignored
  241.  
  242.         ENDC    ;POWERPCLIB_V7
  243.  
  244.  
  245. ****  PPCINFO_CPU (returned by GetCPU and GetInfo)
  246.  
  247.     BITDEF          CPU,603,4
  248.     BITDEF          CPU,603E,8
  249.     BITDEF          CPU,604,12
  250.     BITDEF          CPU,604E,16
  251.     BITDEF          CPU,620,20
  252.  
  253.  
  254. ****  PowerPC Structure transferred to RunPPC, WaitforPPC,
  255. ****  Run68K and WaitFor68K
  256.  
  257.     STRUCTURE       PP,0
  258.     APTR            PP_CODE         ;Ptr to PPC code
  259.     ULONG           PP_OFFSET       ;Offset to PP_CODE
  260.     ULONG           PP_FLAGS        ;flags (see below)
  261.     APTR            PP_STACKPTR     ;stack pointer
  262.     ULONG           PP_STACKSIZE    ;stack size
  263.     STRUCT          PP_REGS,15*4    ;15 registers (d0-a6)
  264.     STRUCT          PP_FREGS,8*8    ;8 registers (fp0-fp7)
  265.     LABEL           PP_SIZE
  266.  
  267. ****  PP_FLAGS
  268.  
  269.     BITDEF          PP,ASYNC,0      ;call PPC/68K in asynchrone mode
  270.  
  271. ****  status returned by RunPPC, WaitForPPC, Run68K and WaitFor68K
  272.  
  273. PPERR_SUCCESS   =       0               ;success
  274. PPERR_ASYNCERR  =       1               ;synchron call after asynchron call
  275. PPERR_WAITERR   =       2               ;WaitFor[PPC/68K] after synchron call
  276.  
  277.  
  278.  
  279.  
  280.  
  281. ****    68K-Assembler macro to open the powerpc.library
  282. *
  283. *       Usage:  OPENPOWERPC     [Version]
  284. *
  285. *       note: The macro POWERDATA (see below) must be defined
  286. *             The base of the exec.library must be defined under the name
  287. *             _SysBase
  288.  
  289. OPENPOWERPC     macro
  290.         movem.l d0/d1/a0/a1/a6,-(sp)
  291.         IFC     "","\1"
  292.         moveq   #0,d0
  293.         ELSEIF
  294.         move.l  #\1,d0
  295.         ENDC
  296.         lea     powerpcname,a1
  297.         move.l  _SysBase,a6
  298.         jsr     -552(a6)
  299.         move.l  d0,_PowerPCBase
  300.         movem.l (sp)+,d0/d1/a0/a1/a6
  301.         endm
  302.  
  303. ****    68K-Assembler macro to close the powerpc.library
  304. *
  305. *       Usage:  CLOSEPOWERPC
  306. *
  307. *       note: The macro POWERDATA (see below) must be defined
  308. *             The base of the exec.library must be defined under the name
  309. *             _SysBase
  310.  
  311. CLOSEPOWERPC    macro
  312.         movem.l d0/d1/a0/a1/a6,-(sp)
  313.         move.l  _SysBase,a6
  314.         move.l  _PowerPCBase,d0
  315.         beq.b   .noclose\@
  316.         move.l  d0,a1
  317.         jsr     -414(a6)
  318. .noclose\@
  319.         movem.l (sp)+,d0/d1/a0/a1/a6
  320.         endm
  321.  
  322. ****    68K-Assembler macro to run a PPC function
  323. *
  324. *       Usage:  RUNPOWERPC_XL Function,[Offset,[Flags,[StackSize,[FPU]]]]
  325. *
  326. *       note: a4 MUST point to the small data section (resp.
  327. *             must have the value _LinkerDB)
  328.  
  329. RUNPOWERPC_XL   macro
  330.         lea     -(PP_SIZE-PP_REGS-15*4)(sp),sp
  331.         movem.l d0-a6,-(sp)
  332.         lea     -PP_REGS(sp),a0
  333.         move.l  a0,sp
  334.         IFC     "FPU","\5"
  335.             lea     PP_FREGS(a0),a1
  336.             fmove.d fp0,(a1)+
  337.             fmove.d fp1,(a1)+
  338.             fmove.d fp2,(a1)+
  339.             fmove.d fp3,(a1)+
  340.             fmove.d fp4,(a1)+
  341.             fmove.d fp5,(a1)+
  342.             fmove.d fp6,(a1)+
  343.             fmove.d fp7,(a1)+
  344.         ENDC
  345.         IFNC    "","\2"
  346.             move.l  \1,a1
  347.             move.l  _LVO\2+2(a1),PP_CODE(a0)
  348.             move.l  a1,PP_REGS+0*4(a0)
  349.         ELSEIF
  350.             XREF    @_\1
  351.             move.l  @_\1,a1
  352. ;                        lea     \1,a1
  353.             move.l  a1,PP_CODE(a0)
  354.         ENDC
  355.         clr.l   PP_OFFSET(a0)
  356.         IFC     "","\3"
  357.             clr.l   PP_FLAGS(a0)
  358.         ELSEIF
  359.             move.l  #\3,PP_FLAGS(a0)
  360.         ENDC
  361.         IFC     "","\4"
  362.             clr.l   PP_STACKPTR(a0)
  363.             clr.l   PP_STACKSIZE(a0)
  364.         ELSEIF
  365.             move.l  sp,PP_STACKPTR(a0)
  366.             add.l   #PP_SIZE,PP_STACKPTR(a0)
  367.             move.l  #\4,PP_STACKSIZE(a0)
  368.         ENDC
  369.         move.l  _PowerPCBase,a6
  370.         jsr     -30(a6)                 ;RunPPC
  371.         IFC     "FPU","\5"
  372.             lea     PP_FREGS(sp),a0
  373.             fmove.d (a0)+,fp0
  374.             fmove.d (a0)+,fp1
  375.             fmove.d (a0)+,fp2
  376.             fmove.d (a0)+,fp3
  377.             fmove.d (a0)+,fp4
  378.             fmove.d (a0)+,fp5
  379.             fmove.d (a0)+,fp6
  380.             fmove.d (a0)+,fp7
  381.         ENDC
  382.         lea     PP_REGS(sp),sp
  383.         movem.l (sp),d0-a6
  384.         lea     (PP_SIZE-PP_REGS)(sp),sp
  385.         endm
  386.  
  387. ****    68K-Assembler macro to run a PPC function (quick version)
  388. *
  389. *       Usage:  RUNPOWERPC Function,[Offset[Flags,[,FPU]]]
  390. *
  391. *       note: a4 MUST point to the small data section (resp.
  392. *             must have the value _LinkerDB)
  393. *
  394. *       this macro does only transfer d0/d1/a0/a1 (and fp0/fp1 with
  395. *       FPU-Option). No stack is transferred. The only return parameter
  396. *       is d0 (fp0/fp1 with FPU-Option). d1/a0/a1 are trashed.
  397.  
  398. RUNPOWERPC      macro
  399.         lea     -PP_SIZE(sp),sp
  400.         move.l  d0,PP_REGS(sp)
  401.         move.l  d1,PP_REGS+1*4(sp)
  402.         move.l  a0,PP_REGS+8*4(sp)
  403.         move.l  a1,PP_REGS+9*4(sp)
  404.         move.l  a4,PP_REGS+12*4(sp)
  405.         move.l  sp,a0
  406.         IFC     "FPU","\5"
  407.             fmove.d fp0,PP_FREGS(a0)
  408.             fmove.d fp1,PP_FREGS+1*8(a0)
  409.         ENDC
  410.         IFNC    "","\2"
  411.             move.l  \1,a1
  412.             move.l  _LVO\2+2(a1),PP_CODE(a0)
  413.             move.l  a1,PP_REGS+0*4(a0)
  414.         ELSEIF
  415.             XREF    @_\1
  416.             move.l  @_\1,a1
  417. ;                        lea     \1,a1
  418.             move.l  a1,PP_CODE(a0)
  419.         ENDC
  420.         clr.l   PP_OFFSET(a0)
  421.         IFC     "","\3"
  422.             clr.l   PP_FLAGS(a0)
  423.         ELSEIF
  424.             move.l  #\3,PP_FLAGS(a0)
  425.         ENDC
  426.         clr.l   PP_STACKPTR(a0)
  427.         clr.l   PP_STACKSIZE(a0)
  428.         move.l  _PowerPCBase,a6
  429.         jsr     -30(a6)                 ;RunPPC
  430.         IFC     "FPU","\5"
  431.             fmove.d PP_FREGS(sp),fp0
  432.             fmove.d PP_FREGS+1*8(sp),fp1
  433.         ENDC
  434.         move.l  PP_REGS(sp),d0
  435.         lea     PP_SIZE(sp),sp
  436.         endm
  437.  
  438.  
  439. ****    68K-Assembler macro to wait for an asynchron PPC process
  440. *
  441. *       Usage:  WAITFORPPC_XL    [FPU]
  442. *
  443.  
  444. WAITFORPPC_XL   macro
  445.         lea     -PP_SIZE(sp),sp
  446.         move.l  sp,a0
  447.         move.l  _PowerPCBase,a6
  448.         jsr     -36(a6)                 ;WaitForPPC
  449.         cmp.l   #PPERR_SUCCESS,d0
  450.         beq.b   .success\@
  451.         lea     PP_SIZE(sp),sp
  452.         bra.b   .exit\@
  453. .success\@
  454.         IFC     "FPU","\1"
  455.             lea     PP_FREGS(sp),a0
  456.             fmove.d (a0)+,fp0
  457.             fmove.d (a0)+,fp1
  458.             fmove.d (a0)+,fp2
  459.             fmove.d (a0)+,fp3
  460.             fmove.d (a0)+,fp4
  461.             fmove.d (a0)+,fp5
  462.             fmove.d (a0)+,fp6
  463.             fmove.d (a0)+,fp7
  464.         ENDC
  465.         lea     PP_REGS(sp),sp
  466.         movem.l (sp),d0-a6
  467.         lea     (PP_SIZE-PP_REGS)(sp),sp
  468. .exit\@
  469.         endm
  470.  
  471. ****    68K-Assembler macro to wait for an asynchron PPC process
  472. *       (quick version)
  473. *
  474. *       Usage:  WAITFORPPC     [FPU]
  475. *
  476. *       The only return parameter is d0 (fp0/fp1 with FPU-Option).
  477. *       d1/a0/a1 are trashed.
  478.  
  479. WAITFORPPC      macro
  480.         lea     -PP_SIZE(sp),sp
  481.         move.l  sp,a0
  482.         move.l  _PowerPCBase,a6
  483.         jsr     -36(a6)                 ;WaitForPPC
  484.         cmp.l   #PPERR_SUCCESS,d0
  485.         bne.b   .exit\@
  486.         IFC     "FPU","\1"
  487.             fmove.d PP_FREGS(sp),fp0
  488.             fmove.d PP_FREGS+1*8(sp),fp1
  489.         ENDC
  490.         move.l  PP_REGS(sp),d0
  491. .exit\@
  492.         lea     PP_SIZE(sp),sp
  493.         endm
  494.  
  495.  
  496. ****    68K-Assembler macro to define some variables required by
  497. *       some other macros (see above)
  498. *
  499. *       Usage:  POWERDATA
  500.  
  501. POWERDATA       macro
  502. _PowerPCBase    dc.l    0
  503. powerpcname     dc.b    "powerpc.library",0
  504.         cnop    0,4
  505.         endm
  506.  
  507.  
  508. ****    PPC-Assembler macro to run a 68K function
  509. *
  510. *       Usage:  RUN68K_XL Function,[Offset,[Flags,[StackSize,[FPU]]]]
  511. *
  512. *       note: the local stackpointer must be properly initialized
  513. *             this macro needs currently 148 bytes of local stack space
  514. *             The base of the powerpc.library must be defined under the name
  515. *             _PowerPCBase
  516. *
  517. *       r7-r10 are trashed
  518.  
  519.  
  520. RUN68K_XL       MACRO
  521.         push    _a6
  522.         subi    local,local,PP_SIZE
  523.         stw     _d0,PP_REGS(local)
  524.         stw     _d1,PP_REGS+1*4(local)
  525.         stw     _d2,PP_REGS+2*4(local)
  526.         stw     _d3,PP_REGS+3*4(local)
  527.         stw     _d4,PP_REGS+4*4(local)
  528.         stw     _d5,PP_REGS+5*4(local)
  529.         stw     _d6,PP_REGS+6*4(local)
  530.         stw     _d7,PP_REGS+7*4(local)
  531.         stw     _a0,PP_REGS+8*4(local)
  532.         stw     _a1,PP_REGS+9*4(local)
  533.         stw     _a2,PP_REGS+10*4(local)
  534.         stw     _a3,PP_REGS+11*4(local)
  535.         stw     _a4,PP_REGS+12*4(local)
  536.         stw     _a5,PP_REGS+13*4(local)
  537.         IFC     "FPU","\5"
  538.             stfd    _fp0,PP_FREGS(local)
  539.             stfd    _fp1,PP_FREGS+1*8(local)
  540.             stfd    _fp2,PP_FREGS+2*8(local)
  541.             stfd    _fp3,PP_FREGS+3*8(local)
  542.             stfd    _fp4,PP_FREGS+4*8(local)
  543.             stfd    _fp5,PP_FREGS+5*8(local)
  544.             stfd    _fp6,PP_FREGS+6*8(local)
  545.             stfd    _fp7,PP_FREGS+7*8(local)
  546.         ENDC
  547.         IFNC    "","\2"
  548.             lw      _d0,\1
  549.             stw     _d0,PP_CODE(local)
  550.             stw     _d0,PP_REGS+14*4(local)
  551.             li      _d0,_LVO\2
  552.         ELSEIF
  553.             stw     _a6,PP_REGS+14*4(local)
  554.             lw      _d0,.routine\@
  555.             stw     _d0,PP_CODE(local)
  556.             li      _d0,0
  557.         ENDC
  558.         stw     _d0,PP_OFFSET(local)
  559.         IFC     "","\3"
  560.             li      _d0,0
  561.         ELSEIF
  562.             liw     _d0,\3
  563.         ENDC
  564.         stw     _d0,PP_FLAGS(local)
  565.         IFC     "","\4"
  566.             li      _d0,0
  567.             stw     _d0,PP_STACKPTR(local)
  568.         ELSEIF
  569.             stw     stack,PP_STACKPTR(local)
  570.             liw     _d0,\4
  571.         ENDC
  572.         stw     _d0,PP_STACKSIZE(local)
  573.         mr      r4,local
  574.         lw      r3,_PowerPCBase
  575.         lwz     r0,-300+2(r3)           ;Run68K
  576.         mtlr    r0
  577.         blrl
  578.         IFC     "FPU","\5"
  579.             lfd     _fp0,PP_FREGS(local)
  580.             lfd     _fp1,PP_FREGS+1*8(local)
  581.             lfd     _fp2,PP_FREGS+2*8(local)
  582.             lfd     _fp3,PP_FREGS+3*8(local)
  583.             lfd     _fp4,PP_FREGS+4*8(local)
  584.             lfd     _fp5,PP_FREGS+5*8(local)
  585.             lfd     _fp6,PP_FREGS+6*8(local)
  586.             lfd     _fp7,PP_FREGS+7*8(local)
  587.         ENDC
  588.         lwz     _d0,PP_REGS(local)
  589.         lwz     _d1,PP_REGS+1*4(local)
  590.         lwz     _d2,PP_REGS+2*4(local)
  591.         lwz     _d3,PP_REGS+3*4(local)
  592.         lwz     _d4,PP_REGS+4*4(local)
  593.         lwz     _d5,PP_REGS+5*4(local)
  594.         lwz     _d6,PP_REGS+6*4(local)
  595.         lwz     _d7,PP_REGS+7*4(local)
  596.         lwz     _a0,PP_REGS+8*4(local)
  597.         lwz     _a1,PP_REGS+9*4(local)
  598.         lwz     _a2,PP_REGS+10*4(local)
  599.         lwz     _a3,PP_REGS+11*4(local)
  600.         lwz     _a4,PP_REGS+12*4(local)
  601.         lwz     _a5,PP_REGS+13*4(local)
  602.         lwz     _a6,PP_REGS+14*4(local)
  603.         addi    local,local,PP_SIZE
  604.         pop     _a6
  605.         IFC     "","\2"
  606.             save
  607.             section "Run68K",data
  608. .routine\@              dc.l    \1
  609.             restore
  610.         ENDC
  611.         ENDM
  612.  
  613. ****    PPC-Assembler macro to run a 68K function (quick version)
  614. *
  615. *       Usage:  RUN68K Function,[Offset,[Flags,[,FPU]]]
  616. *
  617. *       note: the local stackpointer must be properly initialized
  618. *             this macro needs currently 148 bytes of local stack space
  619. *             The base of the powerpc.library must be defined under the name
  620. *             _PowerPCBase
  621. *
  622. *       this macro does only transfer _d0/_d1/_a0/_a1 (and _fp0/_fp1 with
  623. *       FPU-Option). No stack is transferred. The only return parameter
  624. *       is _d0 (_fp0/_fp1 with FPU-Option). r4-r10 are trashed.
  625.  
  626.  
  627. RUN68K          MACRO
  628.         push    _a6
  629.         subi    local,local,PP_SIZE
  630.         stw     _d0,PP_REGS(local)
  631.         stw     _d1,PP_REGS+1*4(local)
  632.         stw     _a0,PP_REGS+8*4(local)
  633.         stw     _a1,PP_REGS+9*4(local)
  634.         stw     _a4,PP_REGS+12*4(local)
  635.         IFC     "FPU","\5"
  636.             stfd    _fp0,PP_FREGS(local)
  637.             stfd    _fp1,PP_FREGS+1*8(local)
  638.         ENDC
  639.         IFNC    "","\2"
  640.             lw      _d0,\1
  641.             stw     _d0,PP_CODE(local)
  642.             stw     _d0,PP_REGS+14*4(local)
  643.             li      _d0,_LVO\2
  644.         ELSEIF
  645.             lw      _d0,.routine\@
  646.             stw     _d0,PP_CODE(local)
  647.             li      _d0,0
  648.         ENDC
  649.         stw     _d0,PP_OFFSET(local)
  650.         IFC     "","\3"
  651.             li      _d0,0
  652.         ELSEIF
  653.             liw     _d0,\3
  654.         ENDC
  655.         stw     _d0,PP_FLAGS(local)
  656.         li      _d0,0
  657.         stw     _d0,PP_STACKPTR(local)
  658.         stw     _d0,PP_STACKSIZE(local)
  659.         mr      r4,local
  660.         lw      r3,_PowerPCBase
  661.         lwz     r0,-300+2(r3)           ;Run68K
  662.         mtlr    r0
  663.         blrl
  664.         IFC     "FPU","\5"
  665.             lfd     _fp0,PP_FREGS(local)
  666.             lfd     _fp1,PP_FREGS+1*8(local)
  667.         ENDC
  668.         lwz     _d0,PP_REGS(local)
  669.         addi    local,local,PP_SIZE
  670.         pop     _a6
  671.         IFC     "","\2"
  672.             save
  673.             section "Run68K",data
  674. .routine\@              dc.l    \1
  675.             restore
  676.         ENDC
  677.         ENDM
  678.  
  679. ****    PPC-Assembler macro to wait for an asynchron 68K process
  680. *
  681. *       Usage:  WAITFOR68K_XL    [FPU]
  682. *
  683. *       r7-r10 are trashed
  684. *       Important: If an AMIGA-OS library function was called using
  685. *       RUN68K or RUN68K_XL then r31 contains the library base!
  686.  
  687.  
  688. WAITFOR68K_XL   macro
  689.         subi    local,local,PP_SIZE
  690.         mr      r4,local
  691.         lw      r3,_PowerPCBase
  692.         lwz     r0,-306+2(r3)           ;WaitFor68K
  693.         mtlr    r0
  694.         blrl
  695.         liw     r0,PPERR_SUCCESS
  696.         cmpw    r3,r0
  697.         bne     .exit\@
  698.         IFC     "FPU","\1"
  699.             lfd     _fp0,PP_FREGS(local)
  700.             lfd     _fp1,PP_FREGS+1*8(local)
  701.             lfd     _fp2,PP_FREGS+2*8(local)
  702.             lfd     _fp3,PP_FREGS+3*8(local)
  703.             lfd     _fp4,PP_FREGS+4*8(local)
  704.             lfd     _fp5,PP_FREGS+5*8(local)
  705.             lfd     _fp6,PP_FREGS+6*8(local)
  706.             lfd     _fp7,PP_FREGS+7*8(local)
  707.         ENDC
  708.         lwz     _d0,PP_REGS(local)
  709.         lwz     _d1,PP_REGS+1*4(local)
  710.         lwz     _d2,PP_REGS+2*4(local)
  711.         lwz     _d3,PP_REGS+3*4(local)
  712.         lwz     _d4,PP_REGS+4*4(local)
  713.         lwz     _d5,PP_REGS+5*4(local)
  714.         lwz     _d6,PP_REGS+6*4(local)
  715.         lwz     _d7,PP_REGS+7*4(local)
  716.         lwz     _a0,PP_REGS+8*4(local)
  717.         lwz     _a1,PP_REGS+9*4(local)
  718.         lwz     _a2,PP_REGS+10*4(local)
  719.         lwz     _a3,PP_REGS+11*4(local)
  720.         lwz     _a4,PP_REGS+12*4(local)
  721.         lwz     _a5,PP_REGS+13*4(local)
  722.         lwz     _a6,PP_REGS+14*4(local)
  723. .exit\@
  724.         addi    local,local,PP_SIZE
  725.         endm
  726.  
  727. ****    PPC-Assembler macro to wait for an asynchron 68K process
  728. *       (quick version)
  729. *
  730. *       Usage:  WAITFOR68K       [FPU]
  731. *
  732. *       The only return parameter is _d0 (_fp0/_fp1 with FPU-Option).
  733. *       r4-r10 are trashed.
  734.  
  735. WAITFOR68K      macro
  736.         subi    local,local,PP_SIZE
  737.         mr      r4,local
  738.         lw      r3,_PowerPCBase
  739.         lwz     r0,-306+2(r3)           ;WaitFor68K
  740.         mtlr    r0
  741.         blrl
  742.         liw     r0,PPERR_SUCCESS
  743.         cmpw    r3,r0
  744.         bne     .exit\@
  745.         IFC     "FPU","\1"
  746.             lfd     _fp0,PP_FREGS(local)
  747.             lfd     _fp1,PP_FREGS+1*8(local)
  748.         ENDC
  749.         lwz     _d0,PP_REGS(local)
  750. .exit\@
  751.         addi    local,local,PP_SIZE
  752.         endm
  753.  
  754.  
  755.     ENDC    ;POWERPC_I
  756.